package org.example.system.common.util;

import java.security.SecureRandom;

public class WxPayUtils {

    // 私用符号
    protected static final String SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    // 安全随机数生成器
    protected static final SecureRandom RANDOM = new SecureRandom();

    // 生成随机字符串
    public static String generateNonceStr() {
        char[] nonceChars = new char[32];
        for (int index = 0; index < nonceChars.length; ++index) {
            nonceChars[index] = SYMBOLS.charAt(RANDOM.nextInt(SYMBOLS.length()));
        }
        return new String(nonceChars);
    }
}
